<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title><fmt:message code="doc.th.AttendancePson" /></title>
    <link rel="stylesheet" href="/css/supervise/statistic.css">
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/lib/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/attend/iconfont.css">
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <script src="/js/common/language.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" 	src="/js/base/tablePage.js"></script>
    <script src="/js/jquery/jquery.cookie.js"></script>
    <style>
        .queryConditon input{
            width:100px;
        }
        .pagediv table tr th{
            /*border-right: 1px solid #c0c0c0;*/
            font-size: 13pt;
        }
        .jump-ipt{
            float: left;
            width: 30px;
            height:30px;
        }
        .TableList {
            border: 1px #dddddd solid;
            line-height: 21px;
            font-size: 9pt;
            border-collapse: collapse;
            padding: 3px;
            margin-top: 8px;
        }
        tbody {
            display: table-row-group;
            vertical-align: middle;
            border-color: inherit;
        }
        .search {
            padding: 6px 10px;
            cursor: pointer;
            color: #ffffff;
            margin-left: 10px;
            background: #2b7fe0;
            border-radius: 4px;
        }
        .xiangqing{
            width: 100%;
            height: 100%;
            margin:18px 0px 0px 0px;
            padding: 1px;
        }
        /*#gerendaochu{
            width: 30px;
            height:30px;
            margin:18px 0px 0px 0px;
            padding: 1px;
        }*/
        .comment{
            float:left;
            margin-left: 10%;
            line-height: 40px;
        }
        .imgSpan{
            font-size: 22px;
            color: #1296db;
        }
        .nameColor{
            color: #651212;
        }.btnSpan{
             width:98px;
         }
    </style>
</head>
<body>
<!--标题导航结束-->
<div class="main">
    <div class="byDepart" style="display: block;">
        <div class="queryConditon">
            <span><fmt:message code="attend.th.AttendanceType" />:</span>
            <select name="" id="attendance" style="width: 100px;height: 28px;margin-left: 5px;border: #ebebeb 1px solid;">
                <%--<option value=""><fmt:message code="attend.th.default" /></option>--%>
            </select>
            <span><fmt:message code="hr.th.department" />:</span>
            <select name="" id="bumen" style="width: 100px;height: 28px;margin-left: 5px;border: #ebebeb 1px solid;"></select>
            <%--<span><fmt:message code="diary.th.body" />:</span>--%>
            <%--<select name="" id="pople" style="width: 100px;height: 28px;margin-left: 5px;border: #ebebeb 1px solid;">--%>
            <%--<option value="" class="all"><fmt:message code="notice.th.all" /></option>--%>
            <%--</select>--%>
            <span><fmt:message code="doc.th.timeFrame" />：</span>
            <input type="text" name="startTime" id="startTimeOne" onclick="laydate(starts)">
            <span style="margin: 0 15px;"><fmt:message code="global.lang.to" /></span>
            <input type="text" name="endTime" id="endTimeOne" onclick="laydate(end)">
            <span class="btnSpan" id="query"><fmt:message code="global.lang.query" /></span>
            <span class="btnSpan" id="outport">导出</span>
            <span class="btnSpan" id="import">导入</span>
            <%--<span class="btnSpan" id="detailsOutport">详细导出</span>--%>
            <%-- 每页展示<input style="width: 35px;"  id="pageNum" value="5" onkeyup="value=value.replace(/[^\d]/g,'')"
             onblur="value=value.replace(/[^\d]/g,'')">条数据
             <img src="../img/sys/icon64_info.png"/>--%>
        </div>

        <div class="queryConditon" style="margin-top:10px;" >

        </div>
        <div class="pagediv" id="already" style="margin: 0 auto;width: 100%;margin-top: 10px;">
            <table>
                <thead>
                <tr>
                    <th>姓名</th>
                    <th>部门</th>
                    <th>应出勤</th>
                    <th>实际出勤</th>
                    <th>全勤</th>
                    <th>上班准时</th>
                    <th>下班准时</th>
                    <th>迟到</th>
                    <th>早退</th>
                    <th>未签到</th>
                    <th>未签退</th>
                    <th>未出勤</th>
                    <th>设备异常</th>
                    <th>外勤</th>
                    <th>请假</th>
                    <th>外出</th>
                    <th>加班</th>
                    <th>出差</th>
                    <th style="width:95px">操作</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
        <div id="dbgz_page" class="M-box3 fr" style="   height: 50px;margin-top:20px">

        </div>
    </div>
</div>

<div class="xiangqing">
    <div class="search" id="gerendaochu" style="display: inline-block;float: right;padding: 6px 20px;font-size: 15px;letter-spacing: 2px;">导出</div><div class="search" id="backs" style="display: inline-block;float: right;padding: 6px 20px;font-size: 15px;letter-spacing: 2px;">返回</div>
    <ul style="width: 30%;height: 68px">
        <li style="font-size: 15px;height: 40px">
            <%--<img src="/img/main_img/theme6/icon_sidebar_mine_03dianji.png" class="comment" >--%>
            <span class="iconfont icon-ren comment imgSpan"></span>
            <span class="comment nameColor" style="margin-left: 4%;">当前用户： <span class="nameColor" id="userName"></span></span>
        </li>
        <li style="font-size: 15px;margin-top: 5px;height: 40px">
            <%-- <img src="/img/commonTheme/theme6/icon_company.png" class="comment" style="height: 33px;">--%>
            <span class="iconfont icon-bumen comment imgSpan"></span>
            <span class="comment nameColor" style="margin-left: 4%;">部门：<span class="nameColor" id="deptName"></span></span>
        </li>
    </ul>
    <table class="TableList"  width="95%" align="center">

    </table>

</div>
<script>
    $(".xiangqing").hide();
    var objJoin=null;
    var starts = {
        format: 'YYYY-MM-DD',
        /* min: laydate.now(), //设定最小日期为当前日期*/
        /* max: '2099-06-16 23:59:59', //最大日期*/
        max: laydate.now(),
        istime: true,
        istoday: false,
        choose: function(datas){
            end.min = datas; //开始日选好后，重置结束日的最小日期
//            end.start = datas //将结束日的初始值设定为开始日
        }
    };
    var end = {
        /*format: 'YYYY/MM/DD hh:mm',*/
        format:'YYYY-MM-DD',
        /*min: laydate.now(),*/
        max: laydate.now(),
        istime: true,
        istoday: false,
        choose: function(datas){
            starts.max = datas; //结束日选好后，重置开始日的最大日期
        }
    };
    var startTime=new Date().Format('yyyy-MM');
    var endTime=new Date().Format('yyyy-MM-dd');
    function check(name){
        if(name == undefined){
            return ''
        }else{
            return name;
        }
    }
    var deptid=$('#bumen').find("option:selected").attr('deptId');
    var exclData={
        deptId:"",
        beginDate:"",
        endDate:"",
        dutyType:""
    }
    var ajaxPage={

        data:{
            pageNo:1,//当前处于第几页
            pageSize:5,//一页显示几条
            uesFlag:true,
            deptId:deptid,
            beginDate:startTime+'-01',
            endDate:endTime,
            dutyType:""
        },
        page:function(){
            var me=this;
            $('#already tbody').html('');
            if(me.data.deptId!=undefined){
                exclData.deptId=me.data.deptId;
            }
            if(me.data.beginDate!=undefined){
                exclData.beginDate=me.data.beginDate;
            }
            if(me.data.dutyType!=undefined){
                exclData.dutyType=me.data.dutyType;
            }
            if(me.data.endDate!=undefined){
                exclData.endDate=me.data.endDate;
            }
            $.ajax({  //列表数据展示
                type:'post',
                url:'/attend/findAttendList2',
                dataType:'json',
                data:me.data,
                success:function(res){
                    var data=res.data;
                    var str='';
                    if(data != undefined && data.length>0){
                        objJoin=data;
                        for(var i=0;i<data.length;i++){
                            str+='<tr uid='+data[i].uid+'>' +
                                '<td >'+data[i].userName+'</td>' +
                                '<td>'+data[i].deptName+'</td>' +
                                '<td>'+data[i].yingchuqin.length+'</td>' +
                                '<td>'+data[i].shijichuqin.length+'</td>' +
                                '<td>'+data[i].quanqin+'</td>' +
                                '<td>'+data[i].shangbanList.length+'</td>' +
                                '<td>'+data[i].xiabanList.length+'</td>' +
                                '<td>'+data[i].chidaoList.length+'</td>' +
                                '<td>'+data[i].zaotuiList.length+'</td>' +
                                '<td>'+data[i].weiqiandaoList.length+'</td>' +
                                '<td>'+data[i].weiqiantuiList.length+'</td>' +
                                '<td>'+data[i].queqinList.length+'</td>' +
                                '<td><a href="javascript:;" uid='+data[i].uid+' name="shebeiyichang" class="tAttend">'+data[i].shebeiyichang.length+'</a></td>' +
                                '<td><a href="javascript:;" uid='+data[i].uid+' name="waiqin" class="tAttend">'+data[i].waiqinList.length+'</a></td>' +
                                '<td><a href="javascript:;" uid='+data[i].uid+' name="qingjia" class="tAttend">'+data[i].qingjia.attendList.length+'</a></td>' +
                                '<td><a href="javascript:;" uid='+data[i].uid+' name="waichu" class="tAttend">'+data[i].waichu.attendList.length+'</a></td>' +
                                '<td><a href="javascript:;" uid='+data[i].uid+' name="jiaban" class="tAttend">'+data[i].jiaban.length+'</a></td>' +
                                '<td><a href="javascript:;" uid='+data[i].uid+' name="chuchai" class="tAttend">'+data[i].chuchai.attendList.length+'</a></td>' +
                                '<td><a href="#" class="particular" deptName="'+data[i].deptName+'" userName="'+data[i].userName+'" uid='+data[i].uid+' style="padding-right:10px"><fmt:message code="file.th.detail" /></a>'+/*<a href="javascript:;" class="personOut" uid='+data[i].uid+'>个人导出</a>*/'</td>' +
                                '</tr>'
                        }
                        $('#already tbody').html(str);
                        $('#dbgz_page').show()
                        me.pageTwo(res.totleNum,me.data.pageSize,me.data.pageNo)
                    }else{
                        $('#dbgz_page').hide()
                    }

                }

            })
        },
        init:function(){
            var deptId=$('#bumen').find("option:selected").attr('deptId');
            $.ajax({//部门选择
                type:'get',
                url: '../../department/getAlldept',
                // data:deptId,
                dataType:'json',
                success:function(res){
                    var data=res.obj;
                    var src ='<option value="">全部部门</option>';
                    for(var i=0;i<data.length;i++){
                        src+='<option value='+data[i].deptId+'>'+data[i].deptName+'</option>'
                    }
                    $('#bumen').html(src)
                }
            });
            $('#bumen').change(function(){
                var deptid=$(this).find("option:selected").attr('deptId');
                var deptId={deptId:deptid}
                $.ajax({//人员展示
                    type:'get',
                    url: '/user/getuserNameByDeptId',
                    data:deptId,
                    dataType:'json',
                    success:function(res){
                        var data=res.obj;
                        var src ='';
                        for(var i=0;i<data.length;i++){
                            src+='<option uid='+data[i].uid+'>'+data[i].userName+'</option>'
                        }
                        $('.all').after(src)
                    }
                })
            });
            $.ajax({  //列表数据展示
                type:'get',
                url:'/attendSet/selsectAttendSet',
                dataType:'json',
                success:function(res){
                    var data=res.obj
                    var attRes='<option value="">全部类型</option>'
                    $.each(data,function (i, item) {
                        attRes+='<option value='+item.sid+'>'+item.title+'</option>'
                    })
                    $("#attendance").append(attRes);
                }
            })
        },
        pageTwo:function (totalData, pageSize,indexs) {//设置分页
            var mes=this;
            $('#dbgz_page').pagination({
                totalData: totalData,
                showData: pageSize,
                jump: true,
                coping: true,
                homePage:'',
                endPage: '',
                current:indexs||1,
                callback: function (index) {
                    mes.data.pageNo=index.getCurrent();
                    mes.page();
                }
            });
        }
    };

    ajaxPage.init();
    ajaxPage.page();

    /* $(document).on('click','.particular',function(){
         var uid = $(this).attr('uid');
         window.location.href = '/attendPage/statisticsDetail?uid='+uid+'&beginDate='+$('#startTimeOne').val()+'&endDate='+$('#endTimeOne').val()
     })*/
    //lr 根据传入的日期字符串返回星期
    function getWeek(dateString){
        var dateArray = dateString.split("-");
        var date = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
        //var weeks = new Array("日", "一", "二", "三", "四", "五", "六");
        //return "星期" + weeks[date.getDay()];
        return dateString+"(星期" + "日一二三四五六".charAt(date.getDay())+")";
    };
    //返回
    $("#backs").click(function () {
        $(".xiangqing").hide();
        $(".main").show();
    });
    $("#gerendaochu").click(function () {
        var uid=$(this).attr("uid");
        if(exclData==null){
            window.location.href="/attend/findAttendList2?deptId="+$('#bumen').val()+'&beginDate='+$('#startTimeOne').val()+'&endDate='+$('#endTimeOne').val()+'&dutyType='+$("#attendance").val()+"exType=2&uid="+uid;
        }
        window.location.href="/attend/findAttendList2?deptId="+exclData.deptId+'&beginDate='+exclData.beginDate+'&endDate='+exclData.endDate+'&dutyType='+exclData.dutyType+"&exType=2&uid="+uid;
    });
    /**
     * @创建作者:李然  Lr
     * @方法描述：详情
     * @创建时间：15:13 2019/3/13
     **/
    $(document).on('click','.particular',function(){
        var uid =$(this).attr("uid");
        $("#gerendaochu").attr("uid",uid);
        var userName=$(this).attr("userName");
        var deptName=$(this).attr("deptName");
        $("#userName").text(userName);
        $("#deptName").text(deptName);
        //异常打卡
        for(var i=0;i<objJoin.length;i++){
            if( objJoin[i].uid == uid ){
                var data=objJoin[i];
                //打卡的对象
                var array = new Object();
                var yishang = new Object()

                //上班
                var shangbanList =data.shangbanList;
                for(var r=0;r<shangbanList.length;r++){
                    array[shangbanList[r]['aTime']] = shangbanList[r];
                }

                //下班
                var xiabanList =data.xiabanList;
                for(var q=0;q<xiabanList.length;q++){
                    array[xiabanList[q]['aTime']] = xiabanList[q];
                }

                //迟到
                var chidaoList =data.chidaoList;
                for(var w=0; w < chidaoList.length; w++){
                    array[chidaoList[w]['aTime']] = chidaoList[w];
                }

                //异常设备
                var shebeiyichang =data.shebeiyichang;
                for(var e=0; e < shebeiyichang.length; e++){
                    yishang[shebeiyichang[e]['aTime']] = shebeiyichang[e];
                }

                var yingchuqinList=data.yingchuqin;
                if(yingchuqinList!=undefined&&yingchuqinList.length>0){
                    var attendHtml='<tr class="TableHeader">\n' +
                        '<td nowrap align="center">日期</td>\n' +
                        '<td nowrap align="center">考勤类型</td>\n' +
                        '<td nowrap align="center">签到1</td>\n' +
                        '<td nowrap align="center">签到2</td>\n' +
                        '<td nowrap align="center">签到3</td>\n' +
                        '<td nowrap align="center">签到4</td>\n' +
                        '<td nowrap align="center">签到5</td>\n' +
                        '<td nowrap align="center">签到6</td>\n' +
                        '</tr>';
                    for(var j=0;j<yingchuqinList.length;j++){
                        var yingchuqin=yingchuqinList[j];
                        var dutyDate = yingchuqin.dutyDate;
                        var attendSet = yingchuqin.attendSet;

                        var trtd='<tr class="TableData">' +
                            '<td nowrap align="center">'+getWeek(dutyDate)+'</td>' +
                            '<td nowrap align="center">'+attendSet.title+'</td>' +
                            '<td nowrap align="center">'+function(){
                                var kaiguan=attendSet.atime1Set.split("|")[0];
                                if(kaiguan==1){
                                    var atimeSetother=attendSet.atime1Setother;
                                    if(atimeSetother==undefined||atimeSetother==0){
                                        atimeSetother="未登记";
                                        if(attendSet.atime1==''){
                                            return atimeSetother
                                        }else{
                                            return "("+attendSet.atime1+")"+" "+atimeSetother
                                        }
                                    }else{
                                        var address = array[ dutyDate + ' ' + atimeSetother ]['address'].split(',');
                                        if(address.length !=3){
                                            return "("+attendSet.atime1+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='maps'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }else{
                                            return "("+attendSet.atime1+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='map' lng = '" + address[0] + "'  lat = '" + address[1] + "'  target='_blank'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }
                                    }
                                }else{
                                    // return "未开启"
                                    return ""
                                }
                            }()+'</td>\n' +
                            '<td nowrap align="center">'+function(){
                                var kaiguan=attendSet.atime2Set.split("|")[0];
                                if(kaiguan==1){
                                    var atimeSetother=attendSet.atime2Setother;
                                    if(atimeSetother==undefined||atimeSetother==0){
                                        atimeSetother="未登记";
                                        if(attendSet.atime2==''){
                                            return atimeSetother
                                        }else{
                                            return "("+attendSet.atime2+")"+" "+atimeSetother
                                        }
                                    }else{
                                        //签到2 正常签到
                                        var address = array[ dutyDate + ' ' + atimeSetother ]['address'].split(',');
                                        if(address.length!=3){
                                            return "("+attendSet.atime2+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='maps'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>" +
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }else{
                                            return "("+attendSet.atime2+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='map'  lng = '" + address[0] + "'  lat = '" + address[1] + "'  target='_blank'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>" +
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }
                                    }
                                }else{
                                    // return "未开启"
                                    return ""
                                }
                            }()+'</td>\n' +
                            '<td nowrap align="center" >'+function(){
                                var kaiguan=attendSet.atime3Set.split("|")[0];
                                if(kaiguan==1){
                                    var atimeSetother=attendSet.atime3Setother;
                                    if(atimeSetother==undefined||atimeSetother==0){
                                        atimeSetother="未登记"
                                        if(attendSet.atime3==''){
                                            return atimeSetother
                                        }else{
                                            return "("+attendSet.atime3+")"+" "+atimeSetother
                                        }
                                    }else{
                                        var address = array[ dutyDate + ' ' + atimeSetother ]['address'].split(',');
                                        if(address.length!=3){
                                            return "("+attendSet.atime3+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='maps'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }else{
                                            return "("+attendSet.atime3+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='map'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }
                                    }
                                }else{
                                    // return "未开启"
                                    return ""
                                }
                            }()+'</td>' +
                            '<td nowrap align="center" >'+function(){
                                var kaiguan=attendSet.atime4Set.split("|")[0];
                                if(kaiguan==1){
                                    var atimeSetother=attendSet.atime4Setother;
                                    if(atimeSetother==undefined||atimeSetother==0){
                                        atimeSetother="未登记";
                                        if(attendSet.atime4==''){
                                            return atimeSetother
                                        }else{
                                            return "("+attendSet.atime4+")"+" "+atimeSetother
                                        }
                                    }else{
                                        var address = array[ dutyDate + ' ' + atimeSetother ]['address'].split(',');
                                        if(address.length !=3){
                                            return "("+attendSet.atime4+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='maps'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }else{
                                            return "("+attendSet.atime4+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='map' lng = '" + address[0] + "'  lat = '" + address[1] + "'  target='_blank'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }
                                    }
                                }else{
                                    // return "未开启"
                                    return ""
                                }
                            }()+'</td>' +
                            '<td nowrap align="center" >'+function(){
                                var kaiguan=attendSet.atime5Set.split("|")[0];
                                if(kaiguan==1){
                                    var atimeSetother=attendSet.atime5Setother;
                                    if(atimeSetother==undefined||atimeSetother==0){
                                        atimeSetother="未登记";
                                        if(attendSet.atime5==''){
                                            return atimeSetother
                                        }else{
                                            return "("+attendSet.atime5+")"+" "+atimeSetother
                                        }
                                    }else{
                                        var address = array[ dutyDate + ' ' + atimeSetother ]['address'].split(',');
                                        if(address.length !=3){
                                            return "("+attendSet.atime5+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='maps'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }else{
                                            return "("+attendSet.atime5+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='map' lng = '" + address[0] + "'  lat = '" + address[1] + "'  target='_blank'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }
                                    }
                                }else{
                                    // return "未开启"
                                    return ""
                                }
                            }()+'</td>' +
                            '<td nowrap align="center" >'+function(){
                                var kaiguan=attendSet.atime6Set.split("|")[0];
                                if(kaiguan==1){
                                    var atimeSetother=attendSet.atime6Setother;
                                    if(atimeSetother==undefined||atimeSetother==0){
                                        atimeSetother="未登记";
                                        if(attendSet.atime6==''){
                                            return atimeSetother
                                        }else{
                                            return "("+attendSet.atime6+")"+" "+atimeSetother
                                        }
                                    }else{
                                        var address = array[ dutyDate + ' ' + atimeSetother ]['address'].split(',');
                                        if(address.length !=3){
                                            return "("+attendSet.atime6+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='maps'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }else{
                                            return "("+attendSet.atime6+")"+
                                                " "+atimeSetother+" "+
                                                "<a class='map' lng = '" + address[0] + "'  lat = '" + address[1] + "'  target='_blank'>" +
                                                "   <img src='../img/position.png' alt='' style='width: 18px'>" +
                                                "</a>" +
                                                "<br>"+
                                                "<span style='color:red;'>" +
                                                function() {
                                                    if( yishang[dutyDate + ' ' + atimeSetother] != undefined ){
                                                        return '代替签到'
                                                    }
                                                    return '正常打卡';
                                                } () +
                                                "</span>";
                                        }
                                    }
                                }else{
                                    // return "未开启"
                                    return ""
                                }
                            }()+'</td>' +
                            '</tr>';
                        attendHtml+=trtd;
                    }
                    if(attendHtml.length>1){
                        $(".TableList").html(attendHtml);
                    }
                    $('.map').click(function () {
                        var lat = $(this).attr('lat');
                        var lng = $(this).attr('lng');
                        window.open('/attendPage/attendanceMap?lat='+lng+'&lng='+lat);
                    })
                    $('.maps').click(function () {
                        alert('暂不支持查看地图')
                    })
                }
                $(".main").hide();
                $(".xiangqing").show();
                break;
            }
        }
    })

    //李然
    //layer组件
    $(document).on('click','.tAttend',function(){
        var str='';
        var type=$(this).attr("name");
        var uid=$(this).attr("uid");
        var title='';
        var object=null;
        for(var i=0;i<objJoin.length;i++){
            if(objJoin[i].uid==uid){
                var data=objJoin[i];
                if(type=="qingjia"){
                    title="请假详情";
                    object=data.qingjia;
                }else if(type=="waichu"){
                    title="外出详情";
                    object=data.waichu;
                }else if(type=="jiaban"){
                    title="加班详情";
                    object=data.jiaban;
                }else if(type=="chuchai"){
                    title="出差详情";
                    object=data.chuchai;
                }else if(type=="shebeiyichang"){
                    title="设备异常";
                    object=data.shebeiyichang;
                }else if(type=="waiqin"){
                    title="外勤详情"
                    object=data.waiqinList;
                }
            }
        }
        var trth='<tr> <th>所属工作</th><th>日期</th></tr>';
        if(object!=null&&object!=undefined){
            if(type=="shebeiyichang"){
                trth='<tr> <th>签到日期</th><th>设备型号</th></tr>';
                if(object.length>0){
                    for(var i=0;i<object.length;i++){
                        var shebeiObject=object[i];
                        var aTime=shebeiObject.aTime;
                        var device=shebeiObject.device;
                        str+= '<tr><td>'+aTime+'</td><td>' + device + '</td></tr>';
                    }
                }
            }else if(type=="jiaban"){
                trth='<tr> <th>加班日期</th><th>加班地址</th></tr>';
                if(object.length>0){
                    for(var i=0;i<object.length;i++){
                        var waiqin=object[i];
                        var aTime=waiqin.aTime;
                        var addressArray=waiqin.address;
                        var address="";
                        if(addressArray!=undefined&&addressArray.length>0){
                            var addressList=addressArray.split(",");
                            address=addressList[addressList.length-1]
                        }
                        str+= '<tr><td>'+aTime+'</td><td>' + address + '</td></tr>';
                    }
                }
            } else if(type=="waiqin"){
                trth='<tr> <th>签到日期</th><th>签到地址</th></tr>';
                if(object.length>0){
                    for(var i=0;i<object.length;i++){
                        var waiqin=object[i];
                        var aTime=waiqin.aTime;
                        var addressArray=waiqin.address;
                        var address="";
                        if(addressArray!=undefined&&addressArray.length>0){
                            var addressList=addressArray.split(",");
                            address=addressList[addressList.length-1]
                        }
                        str+= '<tr><td>'+aTime+'</td><td>' + address + '</td></tr>';
                    }
                }
            } else{
                var attendList=object.attendList;
                if(attendList!=undefined&&attendList.length>0){
                    for(var j=0;j<attendList.length;j++){
                        var attend=attendList[j];
                        var attendDate=attend.attendDate;
                        if(attendDate!=undefined){
                            if(attendDate.length>0){
                                var runName = attend.runName;
                                var tr = '<tr ><td rowspan='+attendDate.length+'>' + runName + '</td><td>' + attendDate[0] + '</td></tr>';
                                if(attendDate.length>1){
                                    for (var c=1;c<attendDate.length;c++) {
                                        tr+= '<tr><td>' + attendDate[c] + '</td></tr>';
                                    }
                                }
                                str+=tr;
                            }

                        }

                    }
                }
            }
        }
        layer.open({
            type: 1,
            /* skin: 'layui-layer-rim', //加上边框 */
            offset: '80px',
            area: ['800px', '400px'], //宽高
            title: title,
            closeBtn: 1,
            content:
                '<table><thead>'+
                trth+
                '</thead>' +
                '<tbody>'+str
                +'</tbody>'+
                '</table>',
            btn: ['关闭'],
        })
    })


    $(document).on('click','.personOut',function(){

        var uid = $(this).attr('uid');
        window.location.href="/attend/outAttend?deptId=&dutyType=&beginDate="+$('#startTimeOne').val()+'&endDate='+$('#endTimeOne').val()+'&uid='+uid;
    })


    $(function(){
        $('#query').click(function(){
            ajaxPage.data.pageNo=1;
            ajaxPage.data.dutyType=$("#attendance").val();
            ajaxPage.data.deptId=$('#bumen').val();
            ajaxPage.data.beginDate=$('#startTimeOne').val();
            ajaxPage.data.endDate=$('#endTimeOne').val();
            ajaxPage.page();
        })
        $('#outport').click(function(){
            if(exclData==null){
                window.location.href="/attend/findAttendList2?deptId="+$('#bumen').val()+'&beginDate='+$('#startTimeOne').val()+'&endDate='+$('#endTimeOne').val()+'&dutyType='+$("#attendance").val()+"&exType=1";
            }
            window.location.href="/attend/findAttendList2?deptId="+exclData.deptId+'&beginDate='+exclData.beginDate+'&endDate='+exclData.endDate+'&dutyType='+exclData.dutyType+"&exType=1";

        })
        $('#detailsOutport').click(function(){
            window.location.href="/attend/exporAttendExcel?deptId="+$('#bumen').val()+'&beginDate='+$('#startTimeOne').val()+'&endDate='+$('#endTimeOne').val()+'&dutyType='+$("#attendance").val()+'&uid=';
        })


        $('#import').click(function(){
            layer.open({
                type:1,
                title: ['信息导入', 'background-color:#2b7fe0;color:#fff;'],
                area: ['500px', '320px'],
                btn: ['导入', '取消'],
                content:'<div>' +
                    '<form class="form1" name="form1" id="uploadForm" method="post" action="/attend/importAttend" enctype="multipart/form-data">' +
                    '<table class="importTable"> ' +
                    '<tr><td style="width: 100px;">下载导入模板：</td><td style="text-align: left;"><a id="model" style="cursor:pointer;text-decoration: underline;color: blue;">考勤信息模板下载</a></td></tr>' +
                    '<tr> <td>选择导入文件：</td> <td style="text-align: left"><input style="width: auto" type="file" name="file"/></td> </tr>' +
                    '<tr>' +
                    '<td>说明：</td>'+
                    '<td style="text-align: left;"><p style="margin-left: 8px">1、请导入.xls或.xlsx文件</p>'+

                    ' </td> ' +
                    '</tr>' +
                    '</table>' +
                    '</form>' +
                    '</div>',
                success:function(){
                    $('#model').click(function () {
                        window.location.href = encodeURI("/file/attend/attendDutyShift.xls");
                    });
                },
                yes:function(obj){
                    var flag = CheckForm();
                    if (flag) {
                        layer.msg("正在导入中，请耐心等候", {icon: 1});
                        $.upload($('#uploadForm'), function (res) {
                            if(res.msg=="导入项目重复"){
                                layer.msg("导入项目重复", {icon: 2});
                            }else
                            if(res.flag) {
                                layer.msg("导入成功", {icon: 1});
                                window.location.reload();
                            }else{
                                layer.msg("导入失败", {icon: 2});
                            }
                        });

                        layer.closeAll();
//
                    }
                }
            })
        })

        function CheckForm(){
            if(document.form1.file.value==""){
                layer.msg("请导入至少一条数据！",{icon:2});
                return (false);
            }
            return (true);
        }


        function init(){//时间初始化
            var d = new Date();
            var vYear = d.getFullYear();
            var vMon = d.getMonth() + 1;
            var vDay = d.getDate();
            if (parseInt(vMon) < 10)
            {
                vMon = "0" + vMon;
            }
            if (parseInt(vDay) < 10)
            {
                vDay = "0" + vDay;
            }
            $("#startTimeOne").val(vYear+"-"+vMon+"-"+"01");
            $("#endTimeOne").val(vYear+"-"+vMon+"-"+vDay)
            var startTimeOne =$("#startTimeOne").val();
            var endTimeOne =$("#endTimeOne").val();

        }init();

        <%--$('.pagediv').on('click','.particular',function(){//查看详情--%>
        <%--var dataId=$(this).parents('tr').attr('uid');--%>
        <%--layer.open({--%>
        <%--type: 1,--%>
        <%--title:['<fmt:message code="roleAuthorization.th.ViewDetails" />'],--%>
        <%--area: ['500px', '300px'], //宽高--%>
        <%--content: '<table >' +--%>
        <%--'<thead><th><fmt:message code="attend.rh.SignDate" /></th><th><fmt:message code="attend.th.SignType" /></th><th><fmt:message code="attend.th.CheckTime" /></th></thead>' +--%>
        <%--'<tbody class="speciality"></tbody>' +--%>
        <%--'</table>',--%>
        <%--success:function(){--%>
        <%--$.ajax({--%>
        <%--url:'/attend/selectAttendParticularss',--%>
        <%--type:'post',--%>
        <%--dataType:'json',--%>
        <%--data:{--%>
        <%--uid:dataId,--%>
        <%--stratDate:$('#startTimeOne').val(),--%>
        <%--endDate:$('#endTimeOne').val()--%>
        <%--},--%>
        <%--success:function(res){--%>
        <%--if(res.flag){--%>
        <%--var data=res.obj;--%>
        <%--var str ='';--%>
        <%--for(var i=0;i<data.length;i++){--%>
        <%--str+='<tr>' +--%>
        <%--'<td>'+data[i].dateStr+'</td>' +--%>
        <%--'<td>'+data[i].atimestate+'</td>' +--%>
        <%--'<td>'+data[i].time+'</td>' +--%>
        <%--'</tr>'--%>
        <%--}--%>
        <%--$('.speciality').html(str);--%>
        <%--}--%>
        <%--}--%>
        <%--})--%>
        <%--}--%>
        <%--});--%>
        <%--})--%>
    });

</script>
</body>
</html>
